//home模块的小仓库

import { reqGetCategoryList, reqGetBannerImg, reqGetFloorList } from '@/api'

const state = {
    categoryList:[],
    bannerImg:[],
    floorList:[]
}
const actions = {
    //获取首页轮播图左侧列表数据
    getCategoryList({commit}) {
        reqGetCategoryList().then((res)=>{
            // console.log(res.data)
            if(res.code == 200) {
                commit('GETCATEGORYLIST',res.data)
            }
        })
    },
    //获取轮播图数据
    getBannerImg({commit}) {
        reqGetBannerImg().then((res)=>{
            //  console.log(res.data)
             if(res.code == 200) {
                commit('GETBANNERIMG',res.data)
            }
        })
    },
    //获取 floor 模块数据
    async getFloorList({commit}){
        let res = await reqGetFloorList()
        if(res.code == 200){
            commit('GETFLOORLIST',res.data)
        }
    }
}
const mutations = {
    GETCATEGORYLIST(state,categoryList) {
        state.categoryList = categoryList
    },
    GETBANNERIMG(state,bannerImg) {
        state.bannerImg = bannerImg
    },
    GETFLOORLIST(state,floorList){
        state.floorList = floorList
    }
}
const getters = {}

export default {
    state,
    actions,
    mutations,
    getters
}
